{extend name="index_layout"/}
{block name="main"}
<form class="layui-form" method="post">
    {:token()}
    <!--    <div class="layui-form-item">-->
    <!--        <label class="layui-form-label">平台</label>-->
    <!--        <div class="layui-input-block">-->
    <!--            {:Form::radios('row[type]',[1=>'抖音', 2=>'快手'], $data.type)}-->
    <!--        </div>-->
    <!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label">分类</label>
        <div class="layui-input-block">
            <select name="row[cid]" lay-filter="fieldType" lay-verify="required">
                <option value=""></option>
                {volist name="cate" id="vo"}
                <option value="{$vo.id}" {if $vo.id==$data.cid}selected{/if}>{$vo.cate_name}</option>
                {/volist}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" name="row[title]" lay-verify="required" autocomplete="off" placeholder="标题"
                   class="layui-input" value="{$data.title}">
        </div>
    </div>

<!--    <div class="layui-form-item">-->
<!--        <label class="layui-form-label">标签</label>-->
<!--        <div class="layui-input-block">-->
<!--            <input type="text" name="row[hashtag]" lay-verify="required" autocomplete="off" placeholder="多个标签以逗号分割"-->
<!--                   class="layui-input" value="{$data.hashtag}">-->
<!--        </div>-->
<!--    </div>-->

    <div class="layui-form-item">
        <label class="layui-form-label">话题</label>
        <div class="layui-input-block">
            {:Form::text('row[hashtag]',$data.hashtag,["class"=>"form-tags"])}
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">类型</label>
        <div class="layui-input-block" onclick="showAnnex()">
            {:Form::radios('row[kind]',[2=>'图片', 4=>'视频'], $data.kind)}
        </div>
    </div>


    <div class="layui-form-item" id="video" style="display: none">
        <label class="layui-form-label layui-form-item-required">视频</label>
        <div class="layui-input-block">
            <div class="layui-col-xs4">
                <input type="text" name="row[video]" id="c-video" value="{$data.video}" class="layui-input">
            </div>
            <button type="button" class="layui-btn faupload" id="faupload-video" data-maxsize="128M" data-multiple="false"
                    data-input-id="c-video" data-preview-id="p-video" data-type="file"><i
                    class="layui-icon layui-icon-upload"></i> 上传
            </button>
<!--            <button type="button" class="layui-btn fachoose" data-multiple="false" data-mimetype="image"-->
<!--                    data-input-id="c-video" id="fachoose-c-video"><i class="iconfont icon-other"></i> 选择-->
<!--            </button>-->

            <button type="button" class="layui-btn" onclick="toVideo()">预览</button>


            <ul class="layui-row list-inline plupload-preview" id="p-video"></ul>
        </div>
    </div>


    <div class="layui-form-item" id="image" style="display: none">
        <label class="layui-form-label layui-form-item-required">图片</label>
        <div class="layui-input-block">
            <div class="layui-col-xs4">
                <input type="text" name="row[pic]" id="c-pic" value="{$data.pic}" class="layui-input">
            </div>
            <button type="button" class="layui-btn faupload" id="faupload-pic" data-multiple="true"
                    data-input-id="c-pic" data-preview-id="p-pic" data-type="image"><i
                    class="layui-icon layui-icon-upload"></i> 上传
            </button>
<!--            <button type="button" class="layui-btn fachoose" data-multiple="true" data-mimetype="image"-->
<!--                    data-input-id="c-pic" id="fachoose-c-pic"><i class="iconfont icon-other"></i> 选择-->
<!--            </button>-->
            <ul class="layui-row list-inline plupload-preview1" id="p-pic"></ul>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="row[sort]" lay-verify="required" autocomplete="off" placeholder="排序"
                   class="layui-input" value="{$data.sort}">
        </div>
    </div>


    <div class="layui-form-item layer-footer">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
{/block}
{block name="script"}
<script type="text/javascript">
    layui.use('yznForm', function () {
        var yznForm = layui.yznForm;
        yznForm.bindevent($("form.layui-form"));
    });

    function toVideo() {
        var url = $('#c-video').val()
        if (url) {
            window.open(url)
        }

    }

    var type = $("input[name='row[kind]']:checked").val()


    if (type == 2) {
        $('#image').show();
        $('#video').hide();

    } else {
        $('#image').hide();
        $('#video').show();
    }


    function showAnnex() {
        var type = $("input[name='row[kind]']:checked").val()
        // $("input[name='row[kind]']").val(null)
        if (type == 2) {
            $('#image').show();
            $('#video').hide();


        } else {
            $('#image').hide();
            $('#video').show();

        }

    }
</script>
{/block}